import { createApp } from 'vue';
import '@/styles/main.scss';
import VueAnimXyz from '@animxyz/vue3';
import '@animxyz/core';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import App from './App.vue';
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import router from './router/route';
import SvgIcon from '@/components/SvgIcon.vue';
import { setupDirectives } from '@/directive';

const app = createApp(App);

// 注册自定义指令
setupDirectives(app);

// 注册Element Plus
app.use(ElementPlus);

// 全局组件注册
import FloatActions from '@/components/FloatActions.vue';
import { registerIcons } from './components/icons';
import { initOrderPolling } from './utils/initOrderPolling';
app.component('FloatActions', FloatActions);

app.component('SvgIcon', SvgIcon);
registerIcons(app);

const pinia = createPinia();
// 注册持久化插件
pinia.use(piniaPluginPersistedstate);

app.use(router).use(pinia).use(VueAnimXyz).mount('#app');

// 初始化订单轮询
initOrderPolling();
